/* Project: POPS
 * CS 279, Vanderbilt University
 * by: Igor I. Ges, Michael S. Parrish, Mark E. Sakauye
 *
 *  This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.popsDB.java.example;

import java.math.*;
import java.util.Date;
import java.util.Collection;
import com.popsDB.java.dao.ItemsDao;
import com.popsDB.java.dto.Items;
import com.popsDB.java.exceptions.ItemsDaoException;
import com.popsDB.java.factory.ItemsDaoFactory;

public class ItemsTests
{
	/**
	 * Method 'main'
	 * 
	 * @param arg
	 * @throws Exception
	 */
	public static void main(String[] arg) throws Exception
	{
		// Uncomment one of the lines below to test the generated code
		
		findAll();
		short tmp = 0;
		findWhereIsActiveEquals(tmp);
	}

	/**
	 * Method 'findAll'
	 * 
	 */
	public static void findAll()
	{
		try {
			ItemsDao _dao = getItemsDao();
			Items _result[] = _dao.findAll();
			String _test[] = new String[6];
			_test[0] = "apples";
			_test[1] = "tomatoes";
			_test[2] = "potatoes";
			_test[3] = "pears";
			_test[4] = "watermelon";
			_test[5] = "peppers";
			
			System.out.println("***** Test Find All *****");
			int count = 0;
			for (int i=0; i<_result.length; i++ ) {
				if (!_result[i].getItemName().toString().equals(_test[i].toString())) {
					count = count + 1;
				}
			}
			if (count == 0) {
				System.out.println("PASSED\n");
			}
			else {
				System.out.println("FAILED\n");
			}
		
		}
		catch (Exception _e) {
			_e.printStackTrace();
		}
		
	}

	public static void findWhereIsActiveEquals(short isActive)
	{
		try {
			ItemsDao _dao = getItemsDao();
			Items _result[] = _dao.findWhereIsActiveEquals(isActive);
			System.out.println("***** Test Where is active = " + isActive 
					+ " *****");
			int count = 0;
			for (int i=0; i<_result.length; i++ ) {
				if (_result[i].getIsActive() != isActive) {
					count = count + 1;
				}
			}
			if (count == 0) {
				System.out.println("PASSED\n");
			}
			else {
				System.out.println("FAILED\n");
			}
		
		}
		catch (Exception _e) {
			_e.printStackTrace();
		}
		
	}

	public static ItemsDao getItemsDao()
	{
		return ItemsDaoFactory.create();
	}

}
